package com.lilosoft.business.task;

import com.lilosoft.core.utils.commons.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import java.util.Date;

/**
 * Spring动态周期定时任务Demo
 * 时间定义：http://cron.qqe2.com/
 */
//@Component
@EnableScheduling
public class DynamicCronTask {

    @Autowired
    private SynchronousPreCity synchronousPreCity;

    @Scheduled(cron = "0 0 19 * * ?")    //每天19点执行
    private void configureTasks() {
        synchronousPreCity.invokeSynchronousByDate( DateUtils.addDays(new Date(), -5), DateUtils.addDays(new Date(), 1));
    }
}
